<?php

namespace app\admin\model\resource;

use think\Model;


class Prop extends Model
{

    

    

    // 表名
    protected $name = 'prop';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'service_mode_text'
    ];
    

    
    public function getServiceModeList()
    {
        return ['' => __('请选择'), '采购' => __('采购'), '租赁' => __('租赁')];
    }


    public function getServiceModeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['service_mode']) ? $data['service_mode'] : '');
        $list = $this->getServiceModeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function merchant()
    {
        return $this->belongsTo('app\admin\model\Merchant', 'merchant_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
